#!/usr/bin/python
# -*- coding:utf-8 -*-
# @author  : micah
# @time    :  
# @function: 
# @version :


import pymysql

def query_data():
    db = pymysql.connect(host='localhost', port=3305, user='root', passwd='123456', db='python_test_1')
    cursor = db.cursor()

    sql = """
    select * from employee where income > %d;
    """ % 10000

    try:
        cursor.execute(sql)
        # 获取所有记录
        results = cursor.fetchall()
        for res in results:
            first_name = res[0]
            last_name = res[1]
            age = res[2]
            sex = res[3]
            income = res[4]
            create_time = res[5]
            print(first_name, last_name, age, sex, income, create_time)
    except Exception as e:
        print('查询有误.', e)
    finally:
        cursor.close()
        db.close()


query_data()

